home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 6728 < prev    next >
Encoding:
Text File  |  1996-08-05  |  902 b   |  45 lines

  1. Path: ip-salem3-15.teleport.com!user
  2. From: dynamix@teleport.com (Steve Budrys)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: ???Recursion and strings
  5. Date: Fri, 09 Feb 1996 13:48:54 -0800
  6. Organization: Dynamix Trading
  7. Message-ID: <dynamix-0902961348540001@ip-salem3-15.teleport.com>
  8. References: <4f44fg$74u@upsidedown.MTS.Net> <31188b9a.12102227@news.kreonet.re.kr>
  9. NNTP-Posting-Host: ip-salem3-15.teleport.com
  10.  
  11. In article <31188b9a.12102227@news.kreonet.re.kr>, jwhahn@cair.kaist.ac.kr
  12. (Jung Hahn) wrote:
  13.  
  14. > foo( char *s, int len)
  15. > {
  16. > static int count=0;
  17. >     if ( count++ < len) {
  18. >         printf( "%c", *s++);
  19. >         foo( s, len);
  20. >         }
  21. > }
  22. > void main( void)
  23. > {
  24. >     char *t = "Hello World\n";
  25. >     foo( t, strlen(t));
  26. > }    
  27.  
  28.  
  29. or if you'd like to use foo more than once,
  30.  
  31. foo(char *s)
  32. {
  33.    if(*s!=0)
  34.    {
  35.       printf(("%c",*s++);
  36.       foo(s);
  37.    }
  38. }
  39.  
  40. -Monique
  41. Dynamix Trading
  42.